package com.xy.singleresponsibility;

/**
 * @author 谢阳
 * @version 1.8.0_131
 * @date 2022/6/7 9:51
 * @description 单一职责方案三
 */
public class SingleResponsibility3 {
    public static void main(String[] args) {
        Vehicle2 vehicle2 = new Vehicle2();
        vehicle2.runRoad("摩托");
        vehicle2.runRoad("汽车");
        vehicle2.runAir("飞机");
        vehicle2.runWater("轮船");
    }
}

/**
 * 方式三分析：
 * 1.没做大修改，只是增加方法
 * 2.虽然没有再类级别上遵守单一职责原则，但在方法上遵守单一职责原则
 */
class Vehicle2 {
    public void runRoad(String vehicle) {
        System.out.println(vehicle + "在路上跑...");
    }

    public void runAir(String vehicle) {
        System.out.println(vehicle + "在空中飞...");
    }

    public void runWater(String vehicle) {
        System.out.println(vehicle + "在水中行...");
    }
}
